/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package it.evento.utils.genpage;

/**
 *
 * @author Mark
 */
public class StringHelper {
     // convert from UTF-8 -> internal Java String format
    public static String convertFromUTF8(String s) {
        String out = null;
        try {
            out = new String(s.getBytes("ISO-8859-1"), "UTF-8");
        } catch (java.io.UnsupportedEncodingException e) {
            return null;
        }
        return out;
    }
 
    // convert from internal Java String format -> UTF-8
    public static String convertToUTF8(String s) {
        String out = null;
        try {
            out = new String(s.getBytes("UTF-8"), "ISO-8859-1");
        } catch (java.io.UnsupportedEncodingException e) {
            return null;
        }
        return out;
    }
 
    /*
    public static void main(String[] args) {
       String input="è é à ò ù";
       String encode=convertToUTF8(input);
       String decode=convertFromUTF8(encode);
       System.out.println("input: "+input);
       System.out.println("encode: "+encode);
       System.out.println("decode: "+decode);
    }
    */
}
